package com.study.jyg.rxjava2study.activity;

import androidx.viewpager.widget.ViewPager;

import com.flyco.tablayout.SlidingTabLayout;
import com.study.jyg.rxjava2study.R;
import com.study.jyg.rxjava2study.adapter.FgTableBean;
import com.study.jyg.rxjava2study.adapter.FgVpAdapter;
import com.study.jyg.rxjava2study.base.BasicActivity;
import com.study.jyg.rxjava2study.base.BasicFragment;
import com.study.jyg.rxjava2study.fragment.VideoFragment;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

public class TabLayoutActivity extends BasicActivity {


    @BindView(R.id.viewPager)
    ViewPager viewPager;
    @BindView(R.id.tabLayout1)
    SlidingTabLayout tabLayout;

    @Override
    protected int getLayout() {
        return R.layout.activity_tab_layout;
    }

    @Override
    protected void initView() {
        initFragmnet();
    }


    private void initFragmnet() {
        List<FgTableBean<BasicFragment>> list = new ArrayList<>();
        list.add(new FgTableBean<>(VideoFragment.newInstance(), "测试1", 0));
        list.add(new FgTableBean<>(VideoFragment.newInstance(), "测试2", 0));
        list.add(new FgTableBean<>(VideoFragment.newInstance(), "测试3", 0));
        list.add(new FgTableBean<>(VideoFragment.newInstance(), "测试4", 0));
        list.add(new FgTableBean<>(VideoFragment.newInstance(), "测试5", 0));

        FgVpAdapter<BasicFragment> adapter = new FgVpAdapter<>(getSupportFragmentManager(), list);
        viewPager.setAdapter(adapter);
//        tabLayout.setViewPager(viewPager);
//        tabLayout.addNewTab();
    }

}